/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidade.controller.JSF.util;

import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author victorinox
 */
public class DateComponentHelper {

    private Date date;

    public DateComponentHelper(Date date) {
        this.date = date;
    }

    /**
     * @return the date
     */
    public Date getDate() {
        return date;
    }

    /**
     * @param date the date to set
     */
    public void setDate(Date date) {
        this.date = date;
    }

    public int getDia() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal.get(Calendar.DAY_OF_MONTH);
    }

    public void setDia(int day) {
        date.setDate(day);
    }

    public int getMes() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal.get(Calendar.MONTH) + 1;
    }

    public void proximoMes(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        date.setMonth(cal.get(Calendar.MONTH) + 1);
    }

    public void setMes(int mes) {
        date.setMonth(mes - 1);
    }

    public int getAno() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal.get(Calendar.YEAR);
    }

    public void setAno(int ano) {
        date.setYear(ano - 1900);
    }
}
